home *** CD-ROM | disk | FTP | other *** search
/ L'Encyclopedie Des Jeux Video 8 / EJV8_CD1.ISO / ejv8-cd1 / viewer.dxr / 00054_Affichage de texte.ls < prev    next >
Encoding:
Text File  |  2003-10-24  |  10.0 KB  |  217 lines

  1. property spriteNum, getPDLError, myDisplayType, mySprite, myMember, myWidthAdjust, myHeightAdjust, myOffStageLoc
  2.  
  3. on getBehaviorDescription me
  4.   return "Affichage de texte" & RETURN & RETURN & "Ce comportement permet d'afficher une cha├«ne donn├⌐e dans un acteur champ ou texte. " & "Utilisez ce comportement avec les comportements 'Info-bulle' et 'Hypertexte - Affichage de l'├⌐tat' qui ont besoin d'un acteur champ ou texte pour afficher leurs informations. " & "Ou cr├⌐ez votre propre Lingo personnalis├⌐ pour afficher des informations d'ex├⌐cution telles que la position de la souris." & RETURN & RETURN & "Ce comportement attend des instructions Lingo. " & "Il n'est pas actif de lui-m├¬me." & RETURN & RETURN & "Vous pouvez choisir entre deux types d'affichage : info-bulle et barre d'├⌐tat." & RETURN & RETURN & "Le type d'affichage 'info-bulle' entra├«ne le redimensionnement de l'acteur champ ou texte de mani├¿re ├á accommoder le texte, et sa disparition lorsqu'il est vide. " & "Vous pouvez r├⌐gler le type d'affichage des info-bulles pour qu'elles apparaissent ├á n'importe quel endroit de la sc├¿ne, tel que sous le curseur. " & "Si aucune position n'est envoy├⌐e ├á l'image-objet, celle-ci appara├«t alors dans le coin sup├⌐rieur gauche de la sc├¿ne. " & "Consultez le comportement Info-bulle pour plus d'informations." & RETURN & RETURN & "Pour afficher plusieurs lignes de texte, vous devrez utiliser des caract├¿res de retour ├á la ligne pour indiquer les passages ├á la ligne. " & "Les images-objets info-bulles sortent de la sc├¿ne lorsqu'elles ne contiennent aucun texte. " & "Il est conseill├⌐ de la placer hors de la sc├¿ne avant son utilisation, au cas o├╣ elle appara├«trait bri├¿vement ├á l'├⌐cran." & RETURN & RETURN & "Le type d'affichage 'barre d'├⌐tat' appara├«t sur la sc├¿ne de fa├ºon permanente. " & "Il n'est pas redimensionn├⌐ et ne change pas de position. " & "Les informations de positionnement envoy├⌐es ├á cette image-objet ne sont pas prises en consid├⌐ration si celle-ci est r├⌐gl├⌐e pour agir en tant que barre d'├⌐tat. " & "Si le texte est trop long pour appara├«tre dans l'acteur de l'image-objet, une barre de d├⌐filement est affich├⌐e. " & "Il n'est pas n├⌐cessaire de diviser le texte ├á l'aide de caract├¿res de retour ├á la ligne. " & "Si vous pensez qu'une barre de d├⌐filement peut ├¬tre n├⌐cessaire, v├⌐rifiez que l'acteur champ ou texte est suffisamment haut pour le bon fonctionnement des fl├¿ches de d├⌐filement." & RETURN & RETURN & "R├⌐glez la taille de la police ainsi que les autres caract├⌐ristiques de l'acteur champ ou texte pour personnaliser l'apparence du message." & RETURN & RETURN & "N'oubliez pas de donner un nom ├á l'acteur champ ou texte. " & "Il est possible que ce comportement le vide. " & "Director efface automatiquement les acteurs vides sans nom." & RETURN & RETURN & "Types d'acteurs autoris├⌐s :" & RETURN & "champ et texte" & RETURN & RETURN & "Param├¿tres :" & RETURN & "* Type d'affichage :" & RETURN & "- Info-bulle (appara├«t pr├¿s du curseur lors du survol)" & RETURN & "- Barre d'├⌐tat (appara├«t ├á une position fixe de fa├ºon permanente)" & RETURN & RETURN & "M├⌐thodes publiques :" & RETURN & "* D├⌐finir le texte ├á afficher (et la position de l'image-objet)" & RETURN & RETURN & "Comportements associ├⌐s :" & RETURN & "* Info-bulle" & RETURN & "* Etat de la source" & RETURN & "* Hypertexte - Affichage de l'├⌐tat"
  5. end
  6.  
  7. on getBehaviorTooltip me
  8.   return "Utilisable avec les acteurs champ ou texte." & RETURN & RETURN & "Attend un message provenant d'un autre comportement ou d'un gestionnaire personnalis├⌐ pour afficher une cha├«ne de caract├¿res. " & "Ce comportement est con├ºu pour ├¬tre utilis├⌐ avec les comportements 'Info-bulle' et 'Hypertexte - Affichage de l'├⌐tat' pour cr├⌐er une barre d'├⌐tat ou une info-bulle sous le curseur."
  9. end
  10.  
  11. on beginSprite me
  12.   myDisplayType = resolve(myDisplayType)
  13.   Initialize(me)
  14. end
  15.  
  16. on endSprite me
  17.   mySprite.visible = 1
  18. end
  19.  
  20. on resolve prop
  21.   case prop of
  22.     myDisplayType:
  23.       choiceslist = ["barre d'├⌐tat (taille et position fixes)", "info-bulle (taille et position dynamiques)"]
  24.       lookup = [#statusbar, #tooltip]
  25.   end case
  26.   return lookup[findPos(choiceslist, prop)]
  27. end
  28.  
  29. on Initialize me
  30.   mySprite = sprite(me.spriteNum)
  31.   myMember = mySprite.member
  32.   if myMember.type = #field then
  33.     myWidthAdjust = (myMember.margin + myMember.border) * 2
  34.     myHeightAdjust = myMember.margin + (myMember.border * 2)
  35.   else
  36.     myWidthAdjust = 0
  37.     myHeightAdjust = 0
  38.   end if
  39.   myMember.text = EMPTY
  40.   if myDisplayType = #tooltip then
  41.     myMember.boxType = #fixed
  42.     myOffStageLoc = point(999, 999)
  43.     mySprite.loc = myOffStageLoc
  44.   end if
  45. end
  46.  
  47. on BestRect me, theString
  48.   myMember.rect = rect(0, 0, 8000, 0)
  49.   myMember.text = theString
  50.   BestRect = myMember.rect
  51.   theLine = the number of lines in theString
  52.   theWidth = 0
  53.   checkedChars = 0
  54.   repeat while theLine
  55.     endOfLine = offset(RETURN, theString)
  56.     if not endOfLine then
  57.       endOfLine = the number of chars in theString + 1
  58.       myMember.text = myMember.text & RETURN
  59.     end if
  60.     checkedChars = checkedChars + endOfLine
  61.     endPoint = charPosToLoc(myMember, checkedChars)
  62.     lineWidth = endPoint[1]
  63.     if lineWidth > theWidth then
  64.       theWidth = lineWidth
  65.     end if
  66.     delete char 1 to endOfLine of theString
  67.     theLine = theLine - 1
  68.   end repeat
  69.   lastChar = myMember.char.count
  70.   lastCharLoc = charPosToLoc(myMember, lastChar)
  71.   theHeight = lastCharLoc[2]
  72.   BestRect[3] = theWidth + 1
  73.   BestRect[4] = theHeight + 1
  74.   return BestRect
  75. end
  76.  
  77. on GetTopLeft me, theLoc, theAlignment, memberRect
  78.   case theAlignment of
  79.     #bottomCenter:
  80.       return theLoc - [memberRect.width / 2, memberRect.height]
  81.     #bottomright:
  82.       return theLoc - [memberRect.width, memberRect.height]
  83.     #bottomleft:
  84.       return theLoc - [0, memberRect.height]
  85.     #center:
  86.       return theLoc - [memberRect.width / 2, memberRect.height / 2]
  87.     #topCenter:
  88.       return theLoc - [memberRect.width / 2, 0]
  89.     #topright:
  90.       return theLoc - [memberRect.width, 0]
  91.     otherwise:
  92.       return theLoc
  93.   end case
  94. end
  95.  
  96. on DisplayText_Enroll me, enrollList
  97.   if ilk(enrollList) <> #list then
  98.     return me
  99.   end if
  100.   if not enrollList.count() then
  101.     enrollList.append(me)
  102.   else
  103.   end if
  104.   return enrollList
  105. end
  106.  
  107. on DisplayText_SetText me, theString, theLoc, theAlignment
  108.   if not stringp(theString) then
  109.     ErrorAlert(me, #invalidString, theString)
  110.     theString = string(theString)
  111.   else
  112.     case ilk(theLoc) of
  113.       #void, #point:
  114.       otherwise:
  115.         ErrorAlert(me, #invalidPoint, theLoc)
  116.         theLoc = point(0, 0)
  117.     end case
  118.   end if
  119.   if (theString = EMPTY) and (myDisplayType = #tooltip) then
  120.     mySprite.loc = myOffStageLoc
  121.   else
  122.     myMember.text = theString
  123.     if myDisplayType = #tooltip then
  124.       memberRect = BestRect(me, theString)
  125.       myMember.rect = memberRect
  126.     else
  127.       memberRect = myMember.rect
  128.     end if
  129.     memberRect = memberRect + [0, 0, myWidthAdjust, myHeightAdjust]
  130.     if myDisplayType = #tooltip then
  131.       if ilk(theLoc) <> #point then
  132.         theLoc = point(0, 0)
  133.       end if
  134.       theLoc = GetTopLeft(me, theLoc, theAlignment, memberRect)
  135.       stageWidth = (the activeWindow).rect.right - (the activeWindow).rect.left
  136.       stageHeight = (the activeWindow).rect.bottom - (the activeWindow).rect.top
  137.       maxH = stageWidth - memberRect.width
  138.       maxV = stageHeight - memberRect.height
  139.       theLoc[1] = max(0, min(theLoc[1], maxH))
  140.       theLoc[2] = max(0, min(theLoc[2], maxV))
  141.       theLoc = theLoc + myMember.regPoint
  142.       mySprite.loc = theLoc
  143.     else
  144.       lastChar = theString.char.count
  145.       textHeight = charPosToLoc(myMember, lastChar)[2]
  146.       if textHeight > mySprite.height then
  147.         myMember.boxType = #scroll
  148.       else
  149.         myMember.boxType = #fixed
  150.       end if
  151.     end if
  152.   end if
  153. end
  154.  
  155. on DisplayText_GetReference me
  156.   return me
  157. end
  158.  
  159. on ErrorAlert me, theError, data
  160.   behaviorName = string(me)
  161.   delete word 1 of behaviorName
  162.   delete char -30001 of behaviorName
  163.   delete char -30001 of behaviorName
  164.   case theError of
  165.     #invalidString:
  166.       if the runMode = "Author" then
  167.         message = substituteStrings(me, "Erreur de comportement : Image ^0, Image-objet ^1" & RETURN & "Comportement ^2" & RETURN & RETURN & "Le gestionnaire 'DisplayText_SetText' ne peut pas traiter l'objet suivant comme une cha├«ne :" & RETURN & "^3", ["^0": the frame, "^1": me.spriteNum, "^2": behaviorName, "^3": data])
  168.         alert(message)
  169.       end if
  170.     #invalidPoint:
  171.       if the runMode = "Author" then
  172.         message = substituteStrings(me, "Erreur de comportement : Image ^0, Image-objet ^1" & RETURN & "Comportement ^2" & RETURN & RETURN & "Le gestionnaire 'DisplayText_SetText' ne peut pas traiter l'objet suivant comme un point :" & RETURN & RETURN & "^3", ["^0": the frame, "^1": me.spriteNum, "^2": behaviorName, "^3": data])
  173.       end if
  174.   end case
  175. end
  176.  
  177. on substituteStrings me, parentString, childStringList
  178.   i = childStringList.count()
  179.   repeat while i
  180.     tempString = EMPTY
  181.     dummyString = childStringList.getPropAt(i)
  182.     replacement = childStringList[i]
  183.     lengthAdjust = dummyString.char.count - 1
  184.     repeat while 1
  185.       position = offset(dummyString, parentString)
  186.       if not position then
  187.         parentString = tempString & parentString
  188.         exit repeat
  189.         next repeat
  190.       end if
  191.       if position <> 1 then
  192.         tempString = tempString & parentString.char[1..position - 1]
  193.       end if
  194.       tempString = tempString & replacement
  195.       delete me.char[1..position + lengthAdjust]
  196.     end repeat
  197.     i = i - 1
  198.   end repeat
  199.   return parentString
  200. end
  201.  
  202. on isOKToAttach me, aSpriteType, aSpriteNum
  203.   case aSpriteType of
  204.     #graphic:
  205.       return getPos([#field, #text], sprite(aSpriteNum).member.type) <> 0
  206.     #script:
  207.       return 0
  208.   end case
  209. end
  210.  
  211. on getPropertyDescriptionList me
  212.   if not (the currentSpriteNum) then
  213.     exit
  214.   end if
  215.   return [#myDisplayType: [#comment: "Affichage de texte se comporte en tant que :", #format: #string, #default: "barre d'├⌐tat (taille et position fixes)", #range: ["barre d'├⌐tat (taille et position fixes)", "info-bulle (taille et position dynamiques)"]]]
  216. end
  217.